package net.pinnoocle.playshoppc.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javafx.scene.layout.VBox;
import net.pinnoocle.playcommon.aop.PassToken;
import net.pinnoocle.playcommon.response.BaseResult;
import net.pinnoocle.playdao.entity.shopPc.ShopLoginParams;
import net.pinnoocle.playdao.entity.shopPc.ShopLoginResultVo;
import net.pinnoocle.playservice.service.CommonService;
import net.pinnoocle.playservice.service.impl.ScriptServiceImpl;
import net.pinnoocle.playservice.service.impl.ShopServiceImpl;
import net.pinnoocle.playservice.service.impl.WxServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author ye
 * @Description
 * @create 2021-10-20 16:56
 */

@RestController
@RequestMapping("/common")
@Api(tags = "公共操作")
public class CommonController {

    @Autowired
    ShopServiceImpl shopService;
    @Autowired
    CommonService commonService;
    @Autowired
    ScriptServiceImpl scriptService;
    @Autowired
    WxServiceImpl wxService;

    @PostMapping("login")
    @ApiOperation("店铺登录")
    public BaseResult<ShopLoginResultVo> login(@Validated @RequestBody ShopLoginParams params){
        return new BaseResult<ShopLoginResultVo>().ok(shopService.shopLogin(params));
    }

    @PostMapping("/uploadFile")
    @ApiOperation("文件上传")
    public BaseResult<String> uploadFiles(@RequestParam("file") MultipartFile file){
        return new BaseResult<String>().ok(commonService.uploadFile(file));
    }

    @GetMapping("scriptLibraryInit")
    @ApiOperation("剧本库初始化")
    public BaseResult<String> scriptLibraryInit(){
        boolean result = scriptService.scriptLibraryInit();
        if(result){
            return new BaseResult<String>().success("初始化成功");
        }
        return new BaseResult<String>().error("初始化失败");
    }
}
